import java.util.Arrays;

/**
 * 452.⽤最少数量的箭引爆⽓球
 */
public class Exerciser4 {
    public int findMinArrowShots(int[][] points) {
        Arrays.sort(points,(v1, v2) -> {
            return v1[0] > v2[0] ? 1 : -1;
        });
        int right = points[0][1];
        int ret = 1;
        for(int i = 1;i < points.length;i++) {
            int a = points[i][0],b = points[i][1];
            if(a <= right) {
                right = Math.min(right,b);
            }else {
                ret++;
                right = b;
            }
        }
        return ret;
    }
}
